usr_info = {"lilei": "123", "wangwu": "456"}
def login(self):      
        for i in range(3):
            usr = input("请输入用户名：")
            pwd = input("请输入密码：")
            if usr in self.usr_info.keys():
                if pwd == self.usr_info[usr]:
                    print("登录成功！")
                else:
                    print("密码输入错误，请重新输入！")
            else:
                print("用户名错误，请重新输入！")
            print("这是第%s次输入错误，还剩%s次机会。" % (i + 1, 2 - i))
        else:
            print("超过最大验证次数，登录失败！")
            break


# 做得不错
